home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revolution - Das Atari CD Magazin 1997
/
Revolution - Das Atari CD Magazin 1.iso
/
software
/
anwendng
/
qed_397
/
sourcen
/
trash.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-12-29
|
6KB
|
233 lines
#include "global.h"
#include "windows.h"
#include "text.h"
#include "edit.h"
#include "desktop.h"
#include "rsc.h"
#include "icon.h"
#include "trash.h"
#include "set.h"
/* exportierte Variablen ***************************************************/
WORD itrash, trash_type;
/****** DEFINES ************************************************************/
#define KIND (NAME|CLOSER|FULLER|MOVER|SIZER|UPARROW|DNARROW|VSLIDE|LFARROW|RTARROW|HSLIDE)
#define FLAGS (WI_TEXT|WI_FONTSIZE)
/****** TYPES **************************************************************/
/****** VARIABLES **********************************************************/
LOCAL TEXTP trash_text;
/****** FUNCTIONS **********************************************************/
LOCAL BOOLEAN wi_key (WINDOWP window, MKINFO *mk);
LOCAL VOID icon_exist (WORD icon, SET actions);
LOCAL BOOLEAN icon_test (WORD icon, WORD action);
LOCAL WORD icon_edit (WORD icon, WORD action);
LOCAL BOOLEAN icon_drag (WORD icon, WORD source);
LOCAL VOID crt_trash (WORD icon, WINDOWP window);
LOCAL BOOLEAN open_trash (WORD icon);
/***************************************************************************/
LOCAL VOID icon_exist(WORD icon, SET actions)
{
setclr(actions);
setincl(actions,DO_CLEAR);
setincl(actions,DO_CLOSE);
setincl(actions,DO_OPEN);
setincl(actions,DO_INFO);
setincl(actions,DO_DESTRUCT);
setincl(actions,DO_HELP);
setincl(actions,DO_INIT);
setincl(actions,DO_REINIT);
}
LOCAL BOOLEAN icon_test(WORD icon, WORD action)
{
WINDP window;
BOOLEAN erg;
window = get_window(icon);
switch (action)
{
case DO_CLEAR :
case DO_INFO :
case DO_CLOSE :
erg = window->opened;
break;
case DO_OPEN :
erg = TRUE;
break;
case DO_DESTRUCT:
erg = TRUE;
break;
case DO_HELP :
erg = TRUE;
break;
case DO_INIT :
erg = TRUE;
break;
case DO_REINIT :
erg = TRUE;
break;
default :
erg = FALSE;
}
return erg;
}
LOCAL WORD icon_edit(WORD icon, WORD action)
{
WORD erg = 1;
WINDOWP window;
CICONBLK *cicon;
window = get_window(icon);
switch (action)
{
case DO_INIT :
trash_text = new_text(icon);
cicon = (CICONBLK *)get_obspec(icons, ITRASH);
set_text_name(trash_text, cicon->monoblk.ib_ptext, TRUE);
create_window (KIND, CLASS_TRASH, icon, crt_trash);
break;
case DO_CLEAR :
clear_text(trash_text);
trash_text->cursor = FALSE;
make_chg(itrash,TOTAL_CHANGE,0);
restore_edit();
break;
case DO_CLOSE :
close_window(window);
break;
case DO_DESTRUCT:
destruct_window(window);
destruct_text(trash_text);
trash_text = NULL;
break;
case DO_OPEN :
if (!open_trash(icon))
erg = -1;
break;
case DO_INFO :
info_edit(icon);
break;
case DO_HELP :
note (1, HELPTRAS);
break;
case DO_REINIT :
trash_text = new_text(itrash);
cicon = (CICONBLK *)get_obspec(icons, ITRASH);
set_text_name(trash_text, cicon->monoblk.ib_ptext, TRUE);
create_window (KIND, CLASS_TRASH,itrash,crt_trash);
break;
}
return erg;
}
/***************************************************************************/
/* Auf den Papierkorb wurde ein Icon gezogen */
/***************************************************************************/
LOCAL BOOLEAN icon_drag (WORD icon, WORD source)
{
return (do_icon(source,DO_CLEAR)!=0);
}
/***************************************************************************/
VOID trash_takes_text(RINGPTR r)
{
TEXTP t_ptr = trash_text;
kill_textring(&t_ptr->text);
t_ptr->text = *r;
FIRST(r)->vorg = &t_ptr->text.head;
LAST(r)->nachf = &t_ptr->text.tail;
t_ptr->cursor_line = FIRST(&t_ptr->text);
make_chg(itrash,TOTAL_CHANGE,0);
}
/***************************************************************************/
LOCAL BOOLEAN wi_key(WINDOWP window, MKINFO *mk)
{
return FALSE;
}
/***************************************************************************/
/* Kreieren eines Fensters */
/***************************************************************************/
LOCAL VOID crt_trash (WORD icon, WINDOWP window)
{
WORD initw, inith;
CICONBLK *cicon;
trash_text->cursor = FALSE;
initw = min ((desk.w / gl_wchar) * gl_wchar - 7 * gl_wchar, 80 * gl_wchar);
inith = (desk.h / gl_hchar) * gl_hchar - 7 * gl_hchar;
window->flags = FLAGS;
window->doc.w = MAX_LINE_LEN;
window->doc.h = trash_text->text.lines;
window->xfac = gl_wchar;
window->yfac = gl_hchar;
window->w_width = initw/gl_wchar;
window->w_hight = inith/gl_hchar;
window->work.x = sys_wchar;
window->work.y = 42;
window->work.w = initw;
window->work.h = inith;
window->draw = wi_draw_edit; /* gleiche Routinen wie für EDIT */
window->key = wi_key;
cicon = (CICONBLK *)get_obspec(icons, ITRASH);
set_wname(window, cicon->monoblk.ib_ptext);
} /* crt_trash */
/***************************************************************************/
/* Öffnen des Objekts */
/***************************************************************************/
LOCAL BOOLEAN open_trash (WORD icon)
{
BOOLEAN ok;
WINDOWP window;
window = get_window (icon);
if (window==NULL) return FALSE;
if (window->opened)
/* Doppelklick auf Icon und Fenster ist schon offen */
{
top_window (window);
ok = TRUE;
}
else
{
ok = open_window(window);
}
return (ok);
} /* open_trash */
/***************************************************************************/
VOID init_trash (VOID)
{
CICONBLK *cicon;
trash_type = decl_icon_type(icon_test,icon_edit,icon_exist,icon_drag);
cicon = (CICONBLK *)get_obspec(icons, ITRASH);
itrash = add_icon_to_desk(ITRASH, cicon->monoblk.ib_ptext, -1, -1);
add_icon(trash_type,itrash);
}